package git.soulbgm.security.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 读取application-authority.properties配置文件
 *
 * @author SoulBGM
 * @version 1.0
 * @date 2020-08-07
 */
@Component
@ConfigurationProperties(prefix = "authority")
@Data
public class AuthorityConfig {

    /**
     * 登录方式 1 cookie 2 token
     */
    private Integer loginMode = 1;

    /**
     * 是否过滤所有请求(开发时使用,这样所有请求不去拦截)
     */
    private Boolean filterAll;

    /**
     * 匿名访问的URL
     */
    private String[] anonymous;

    /**
     * 允许访问的URL
     */
    private String[] permitAll;

    /**
     * 登录之后才能访问的URL
     */
    private String[] authenticated;

    /**
     * 同一用户允许最多有几个会话
     */
    private Integer maximumSessions = 1;

    /**
     * 当达到最多会话时是否禁止用户登录
     */
    private Boolean maxSessionsPreventsLogin = false;

    /**
     * 用户初始密码
     */
    private String initPassword;

    /**
     * 令牌自定义标识
     */
    private String tokenHeader;

    /**
     * 令牌密钥
     */
    private String tokenSecret;

    /**
     * 令牌有效期（默认30分钟）
     */
    private Integer tokenExpireTime = 30;

    public Integer getLoginMode() {
        return loginMode;
    }

    public void setLoginMode(Integer loginMode) {
        this.loginMode = loginMode;
    }

    public Boolean getFilterAll() {
        return filterAll;
    }

    public void setFilterAll(Boolean filterAll) {
        this.filterAll = filterAll;
    }

    public String[] getAnonymous() {
        return anonymous;
    }

    public void setAnonymous(String[] anonymous) {
        this.anonymous = anonymous;
    }

    public String[] getPermitAll() {
        return permitAll;
    }

    public void setPermitAll(String[] permitAll) {
        this.permitAll = permitAll;
    }

    public String[] getAuthenticated() {
        return authenticated;
    }

    public void setAuthenticated(String[] authenticated) {
        this.authenticated = authenticated;
    }

    public Integer getMaximumSessions() {
        return maximumSessions;
    }

    public void setMaximumSessions(Integer maximumSessions) {
        this.maximumSessions = maximumSessions;
    }

    public Boolean getMaxSessionsPreventsLogin() {
        return maxSessionsPreventsLogin;
    }

    public void setMaxSessionsPreventsLogin(Boolean maxSessionsPreventsLogin) {
        this.maxSessionsPreventsLogin = maxSessionsPreventsLogin;
    }

    public String getInitPassword() {
        return initPassword;
    }

    public void setInitPassword(String initPassword) {
        this.initPassword = initPassword;
    }

    public String getTokenHeader() {
        return tokenHeader;
    }

    public void setTokenHeader(String tokenHeader) {
        this.tokenHeader = tokenHeader;
    }

    public String getTokenSecret() {
        return tokenSecret;
    }

    public void setTokenSecret(String tokenSecret) {
        this.tokenSecret = tokenSecret;
    }

    public Integer getTokenExpireTime() {
        return tokenExpireTime;
    }

    public void setTokenExpireTime(Integer tokenExpireTime) {
        this.tokenExpireTime = tokenExpireTime;
    }
}
